<?php
class Users_model extends CI_Model{
	
	function username_check($username) {
		$this->db->where('username',$username);
		$query = $this->db->get('users');
		if($query->num_rows()>0){
			return false;
		}else
			return true;
	}
	
	function email_check($email) {
		$this->db->where('email',$email);
		$query = $this->db->get('users');
		if($query->num_rows()>0){
			return false;
		}else
			return true;
	}
	
	function insert_user($name,$username,$email,$password){
		$data = array(
			'name'			=>$name,
			'username'		=>$username,
			'email'			=>$email,
			'password'		=>$password
		);
		
		return $this->db->insert('users',$data);
	}
	
	function verify_login($username,$password){
		$this->db->where('username', $username);
		$this->db->where('password', $password);
		$query = $this->db->get('users');
		if($query->num_rows()>0){
			$result = $query->result();
			if($result[0]->status==1)
				return $result;
			else
				return false;
		}else
			return false;
	}
}